#{extends 'layout.html' /}
#{set title:messages.get('crud.list.title', '留言信息') /}

<style type="text/css">
 a{ text-decoration: none;}
</style>
<script type="text/javascript" src="@{'/public/javascripts/jquery-1.6.4.min.js'}"></script>
<link rel="stylesheet" href="/public/stylesheets/alert.css" type="text/css" />
   <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" src="/public/javascripts/adu.alert.js"></script>
<div id="crudList" class="">
    <div id="crudListTable">
    	<table>
                <thead>
			      <tr>
			      	<th width="30%">编号</th>
			        <th width="50%">会员名称</th>
			        <th width="50%">留言时间</th>
			        <th width="50%">留言内容</th>
			        <th width="50%">留言状态</th>
			        <th width="50%">操作</th>
			      </tr>
			    </thead>
   		#{list items:leaList,as:'lea'}
	   		<tr>
		   		<td>${lea.id}</td>
		   		<td>${lea.member.memnum}</td>
		   		<td>${lea.lemTime}</td>
		   		<td>${lea.lemDet}</td>
		   		<td>
		   			${lea.state == 0 ? "审核中":""}
		   			${lea.state == 1 ? "审核通过":""}
		   		</td>
		   		<td>
			   		#{if lea.lerDet == null}
			   			<a href="@{show(lea.id)}"><font>[留言回复]</font></a>
			   		#{/if}
			   		#{else}
		   				<a href="@{show(lea.id)}">查看详情</a>
		   			#{/else}
		   			<a href="@{deleteLea(lea.id)}" onclick="return confirm('确定要删除吗！')">  　[删除]</a>
		   			#{if lea.state == 0}
		   				<a onclick="sub(${lea.id});" href="javascript:void(0);">　　[通过审核]</a>
		   			#{/if}
		   			#{else}
		   				<span></span>
		   			#{/else}
	   			</td>
	   		</tr>
   		#{/list}
     </table>
    </div>
     <div id="crudListPagination">
        <p class="crudCount">
		    ${count?:0}
		</p>
		
		#{if pages > 1}
		    <p class="crudPages">
		
		        %{
		            limit = (offset != null ? offset : 10)
		            start = page - (int)(limit/2) + (limit % 2 ? 0 : 1)
		            end = page + (int)(limit/2)
		
		            if(start < 1){
		                extra = 1 - start
		                end = (end + extra < pages ? end + extra : pages)
		                start = 1
		            }else if(end > pages){
		                extra = end - pages
		                start = (start - extra > 1 ? start - extra : 1)
		                end = pages
		            }
		        }%
		
		        #{if page > 1}
		            <span class="previous">
		            	<a href="@{LeaMesAction.list(page-1, size)}">上一页</a>
		            </span>
		        #{/if}
		
		        #{if start > 1}
		            <span class="first">
		            	<a href="@{LeaMesAction.list(1, size)}">第一页</a>
		            </span>
		        #{/if}
		
		        %{ for (i in start..end) { }%
		            <span class="page">
		                #{if page == i}
		                    <strong>${i}</strong>
		                #{/if}
		                #{else}
		                	<a href="@{LeaMesAction.list(i, size)}">${i}</a>
		                #{/else}
		            </span>
		        %{ } }%
		
		        #{if end < pages}
		            <span class="last">
		            	<a href="@{LeaMesAction.list(pages, size)}">最后一页</a>
		            </span>
		        #{/if}
		
		        #{if page < pages}
		            <span class="next">
		            	<a href="@{LeaMesAction.list(page+1, size)}">下一页</a>
		            </span>
		        #{/if}
		
		    </p>
		#{/if}
    </div>
    <!-- 
    <p id="crudListAdd">
        <a href="@{blank()}">添加留言</a>
    </p>
     -->
</div>

<script type="text/javascript">
	function sub (leaid){
		$.ajax({
			type:'post',
			url :'/controllers/LeaMesAction.passlea',
			data:({"leaid":leaid}),
			dataType:'html',
			success:function(e){
				if(e == "1"){
					aduAlert("审核通过！","提示",function(){
						window.location.href = "/controllers/LeaMesAction.list"
					});
				}
				if(e == "0"){
					aduAlert("审核通过失败！","提示");
				}
			}   
		});
	}
</script>
